﻿using DMSkin.Core;
using Dt261.Views;
using GalaSoft.MvvmLight;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;

namespace Dt261.ViewModel
{
    class WindowXViewModel : DMSkin.Core.ViewModelBase
    {

        public WindowXViewModel()
        {
            navchange("5");
        }

        private UserPage up;
        private SettingPage sp;
        private DeviceWindow dw;
        private AboutPage ap;
        private ChangePsw cp;
        private PureToneCorrect cor;

        public UserPage Up
        {
            get
            {
                if (up == null)
                {
                    up = new UserPage();
                }
                return up;
            }
            set => up = value;
        }

        public PureToneCorrect Cor
        {
            get
            {
                if (cor == null)
                {
                    cor = new PureToneCorrect();
                }
                return cor;
            }
            set => cor = value;
        }

        public ICommand NavigationCommand => new DelegateCommand(obj => navchange((string)obj));

        public SettingPage Sp
        {
            get
            {
                if (sp == null)
                {
                    sp = new SettingPage();
                }
                return sp;
            }
            set => sp = value;
        }

        public string IsSuperUser
        {

            get
            {
                return GlobalData.IsSuperUser() ? "Visible" : "Hidden";
            }
        }

        public DeviceWindow Dw
        {
            get
            {
                if (dw == null)
                {
                    dw = new DeviceWindow();
                }
                return dw;
            }
            set => dw = value;
        }
        public AboutPage Ap
        {
            get
            {
                if (ap == null)
                {
                    ap = new AboutPage();
                }
                return ap;
            }
            set => ap = value;
        }

        public ChangePsw Cp
        {
            get
            {
                if (cp == null)
                    cp = new ChangePsw();
                return cp;
            }
            set => cp = value;
        }

        public void navchange(string obj)
        {
            int menu = int.Parse((string)obj);
            switch (menu)
            {
                case 1:
                    Broadcast.PushBroadcast("Navigation", Up);
                    break;
                case 3:
                    Broadcast.PushBroadcast("Navigation", Sp);
                    break;
                case 2:
                    Broadcast.PushBroadcast("Navigation", Dw);
                    break;
                case 4:
                    Broadcast.PushBroadcast("Navigation", Ap);
                    break;

                case 5:
                    Broadcast.PushBroadcast("Navigation", Cp);
                    break;
                case 6:
                    Broadcast.PushBroadcast("Navigation", Cor);
                    break;
            }
        }
    }
}



